import cv2
import numpy as np
import os
from glob import glob

def edge2(filename):
    img = cv2.imread(filename, cv2.IMREAD_GRAYSCALE)

    # 虽然没了躁点，但是边缘导致线条是内外双层线
    img_edge = cv2.Canny(img, 50, 100, (5, 5))

    save_filename = '%s.png' % (os.path.basename(filename).split('.')[0])
    cv2.imwrite('images/lineFrames2/' + save_filename, img_edge)



if __name__ == "__main__":
    file_list = glob('images/frames/*.png')
    for filename in file_list:
        edge2(filename)